package com.ruoyi.common.utils;



import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;

import java.io.IOException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;


// ✅ 正确实现：继承 JsonDeserializer
public class CustomLocalDateTimeDeserializer extends JsonDeserializer<LocalDateTime> {  // 关键修改点：父类为 JsonDeserializer

    private static final DateTimeFormatter FORMATTER =
            DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

    @Override
    public LocalDateTime deserialize(JsonParser p, DeserializationContext ctxt)
            throws IOException {
        String dateStr = p.getText();
        return LocalDateTime.parse(dateStr, FORMATTER);
    }
}